// 通用响应类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
}

// 分页响应类型
export interface PaginatedResponse<T> {
  list: T[]
  total: number
  page: number
  pageSize: number
}

// 用户相关类型
export interface User {
  id: number
  username: string
  email: string
  phone?: string
  avatar?: string
  status: 'active' | 'inactive' | 'banned'
  roles: Role[]
  createdAt: string
  updatedAt: string
}

export interface CreateUserRequest {
  username: string
  email: string
  password: string
  phone?: string
  roleIds: number[]
}

export interface UpdateUserRequest {
  id: number
  username?: string
  email?: string
  phone?: string
  status?: 'active' | 'inactive' | 'banned'
  roleIds?: number[]
}

export interface UserListParams {
  page?: number
  pageSize?: number
  keyword?: string
  status?: string
  roleId?: number
}

// 角色相关类型
export interface Role {
  id: number
  name: string
  code: string
  description?: string
  status: 'active' | 'inactive'
  permissions: Permission[]
  userCount?: number
  createdAt: string
  updatedAt: string
}

export interface CreateRoleRequest {
  name: string
  code: string
  description?: string
  permissionIds: number[]
}

export interface UpdateRoleRequest {
  id: number
  name?: string
  code?: string
  description?: string
  status?: 'active' | 'inactive'
  permissionIds?: number[]
}

export interface RoleListParams {
  page?: number
  pageSize?: number
  keyword?: string
  status?: string
}

// 权限相关类型
export interface Permission {
  id: number
  name: string
  code: string
  type: 'menu' | 'button' | 'api'
  parentId?: number
  path?: string
  method?: string
  description?: string
  status: 'active' | 'inactive'
  children?: Permission[]
  createdAt: string
  updatedAt: string
}

export interface CreatePermissionRequest {
  name: string
  code: string
  type: 'menu' | 'button' | 'api'
  parentId?: number
  path?: string
  method?: string
  description?: string
}

export interface UpdatePermissionRequest {
  id: number
  name?: string
  code?: string
  type?: 'menu' | 'button' | 'api'
  parentId?: number
  path?: string
  method?: string
  description?: string
  status?: 'active' | 'inactive'
}

export interface PermissionListParams {
  keyword?: string
  type?: string
  status?: string
  parentId?: number
}

// 认证相关类型
export interface LoginRequest {
  username: string
  password: string
}

export interface LoginResponse {
  token: string
  user: User
  permissions: string[]
}

export interface RegisterRequest {
  username: string
  email: string
  password: string
  confirmPassword: string
}

// 仪表盘统计类型
export interface DashboardStats {
  userCount: number
  roleCount: number
  permissionCount: number
  onlineUserCount: number
}

export interface AccessTrend {
  date: string
  count: number
}

export interface UserDistribution {
  name: string
  value: number
}

export interface RecentActivity {
  id: number
  type: 'login' | 'logout' | 'create' | 'update' | 'delete'
  user: string
  description: string
  timestamp: string
}

export interface SystemStatus {
  cpu: number
  memory: number
  disk: number
  network: number
}

// 系统配置类型
export interface SystemConfig {
  siteName: string
  siteDescription: string
  logo?: string
  favicon?: string
  allowRegistration: boolean
  emailVerification: boolean
  sessionTimeout: number
}

// 操作日志类型
export interface OperationLog {
  id: number
  user: string
  action: string
  resource: string
  details: string
  ip: string
  userAgent: string
  timestamp: string
}

export interface LogListParams {
  page?: number
  pageSize?: number
  user?: string
  action?: string
  resource?: string
  startDate?: string
  endDate?: string
}